/**
 * 消息记录
 */
layui.define(['index', 'flying'], function (exports) {  //先加载index模块，里面配置了全局的入口
  const admin = layui.admin,
      flying = layui.flying
      ,form = layui.form
      ,table = layui.table
      ,layer = layui.layer
      ,dropdown = layui.dropdown;

  flying.table({
    elem: '#LAY-msg-info-table',
    url: '/message/info/page', //数据接口
    cols: [
      {type: 'numbers', fixed: 'left', title: '序号'}
      , {field: 'serviceName', title: '所属应用', templet: function (d) {
          return flying.convertDict(serviceNameList, d.serviceName);
        }, minWidth: 100}
      , {field: 'title', title: '消息标题', minWidth: 100}
      , {field: 'account', title: '推送账号', minWidth: 150}
      , {field: 'content', title: '推送内容', minWidth: 250}
      , {field: 'status', title: '发送状态', width: 100, templet: function(d){
          if(d.status === 'S'){
            return '<span class="layui-badge layui-bg-green">成功</span>';
          } else if(d.status === 'F'){
            return '<span class="layui-badge layui-bg-orange">失败</span>';
          } else {
            return '<span class="layui-badge layui-bg-gray">未知</span>';
          }
        }, unresize: true}
      , {field: 'mode', title: '发送方式', width: 100, templet: function(d){
          if(d.mode === 'S'){
            return '<span>短信</span>';
          } else if(d.mode === 'M'){
            return '<span>邮件</span>';
          } else {
            return '<span>未知</span>';
          }
        }, unresize: true}
      , {field: 'updatedTime', title: '推送时间', templet: '<div>{{ layui.util.toDateString(d.createdTime, "yyyy-MM-dd HH:mm:ss") }}</div>', minWidth: 170, sort: true}
      // , {title: '操作', width: 160, align: 'center', fixed: 'right', toolbar: '#msg-info-table'}
    ]
  });

  const mssTpl = {
    // // 删除
    // handleDelete: function (index, procInstId) {
    //   //提交 Ajax 成功后，更新表格中的数据
    //   admin.req({
    //     url: '/flow/msg-tpl/delete'
    //     , type: 'post'
    //     , data: {"procInstId": procInstId, "reason": '作废删除'}
    //     , done: function (res) {
    //       //执行成功
    //       layer.msg(res.msg, {icon: 1});
    //       table.reload('LAY-msg-info-table'); //数据刷新
    //       layer.close(index); //关闭弹层
    //     }
    //   });
    // }
  }

  //对外暴露的接口
  exports('mssTpl', mssTpl);
});